﻿using System;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class _DadosCurso : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] == null)
            Response.Write("mensagens.aspx?id=1");
        else
        {
            SqlConnection conexaoIntranet = new SqlConnection(ConfigurationManager.ConnectionStrings["conexao_intranet"].ConnectionString);
            SqlCommand consultaCurso = null;
            SqlDataReader drCurso;
            try
            {
                if (conexaoIntranet != null && conexaoIntranet.State != ConnectionState.Open)
                    conexaoIntranet.Open();
                string instrucao = "SELECT Curso, Descricao, CH FROM CamaraCursos WHERE CodCurso = " + Request.QueryString["id"].ToString();
                consultaCurso = new SqlCommand(instrucao, conexaoIntranet);
                drCurso = consultaCurso.ExecuteReader();
                if (drCurso.HasRows)
                {
                    drCurso.Read();
                    lblCurso.Text = drCurso["Curso"].ToString();
                    lblCH.Text = "Carga Horária: " + drCurso["CH"].ToString() + " horas";
                    lblDescricao.Text = drCurso["Descricao"].ToString();
                }
                drCurso.Close();
            }
            finally
            {
                conexaoIntranet.Close();
            }
        }
    }
}